package notifymessage

import (
	"context"
	v1 "ruoyi-vue-pro-go/api/notifymessage/v1"
	"ruoyi-vue-pro-go/internal/dao"
	"ruoyi-vue-pro-go/internal/model/do"
	"ruoyi-vue-pro-go/internal/service"
)

type (
	sNotifyMessage struct{}
)

func init() {
	service.RegisterNotifyMessage(New())
}

func New() service.INotifyMessage {
	return &sNotifyMessage{}
}

func (s *sNotifyMessage) GetUnreadCount(ctx context.Context, req *v1.GetUnreadCountReq) (res *v1.GetUnreadCountRes, err error) {
	res = &v1.GetUnreadCountRes{}
	count, err := dao.SystemNotifyMessage.Ctx(ctx).Where(do.SystemNotifyMessage{
		ReadStatus: 0,
	}).Count()
	res.Count = count
	return
}
